package com.grass.p019lv.activity;

import androidx.recyclerview.widget.LinearLayoutManager;
import com.alibaba.android.arouter.launcher.ARouter;
import com.androidsa.bttsddka.R;
import com.androidx.p013lv.base.Constance;
import com.androidx.p013lv.base.bean.InventionBean;
import com.androidx.p013lv.base.bean.InventionListBean;
import com.androidx.p013lv.base.bean.TwoBean;
import com.androidx.p013lv.base.bean.UserInfo;
import com.androidx.p013lv.base.dialog.DialogLoading;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.http.HttpUtils;
import com.androidx.p013lv.base.http.JsonParams;
import com.androidx.p013lv.base.http.UrlManager;
import com.androidx.p013lv.base.http.callback.HttpCallback;
import com.androidx.p013lv.base.interfaces.Key;
import com.androidx.p013lv.base.p015ui.BaseActivity;
import com.androidx.p013lv.base.utils.NetUtil;
import com.androidx.p013lv.base.utils.ToastUtils;
import com.androidx.p013lv.invention.OnInventionType;
import com.grass.p019lv.adapter.svip.AdapterSvipType;
import com.grass.p019lv.databinding.ActivitySvipBinding;
import com.grass.p019lv.dialog.SvipDialog;
import com.gyf.immersionbar.ImmersionBar;

/* renamed from: com.grass.lv.activity.SvipActivity */
public class SvipActivity extends BaseActivity<ActivitySvipBinding> implements OnInventionType {
    private AdapterSvipType adapterSvipType;
    private DialogLoading loading;

    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public int setLayout() {
        return R.layout.activity_svip;
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).titleBar(((ActivitySvipBinding) this.binding).toolbar).init();
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initView() {
        super.initView();
        DialogLoading dialogLoading = new DialogLoading(this);
        this.loading = dialogLoading;
        dialogLoading.setTvHint("");
        ((ActivitySvipBinding) this.binding).setClick(new OnClick());
        getUserInfo();
        ((ActivitySvipBinding) this.binding).recycler.setLayoutManager(new LinearLayoutManager(this));
        this.adapterSvipType = new AdapterSvipType(this, null);
        ((ActivitySvipBinding) this.binding).recycler.setAdapter(this.adapterSvipType);
        getInfo();
    }

    private void getUserInfo() {
        HttpUtils.getInsatance().post(UrlManager.getInsatance().userInfo(), JsonParams.build().commit(), new HttpCallback<BaseRes<UserInfo>>("userInfo") {
            /* class com.grass.p019lv.activity.SvipActivity.C29071 */

            public void onLvSuccess(BaseRes<UserInfo> baseRes) {
                if (SvipActivity.this.binding != null && 200 == baseRes.getCode() && !baseRes.getData().isSvip()) {
                    new SvipDialog(SvipActivity.this).show();
                }
            }
        });
    }

    /* access modifiers changed from: package-private */
    public void getInfo() {
        if (NetUtil.isNetworkAvailable()) {
            this.loading.show();
            HttpUtils.getInsatance().get(UrlManager.getInsatance().querySvipStations(), new HttpCallback<BaseRes<InventionListBean>>("HTTP_TAG") {
                /* class com.grass.p019lv.activity.SvipActivity.C29082 */

                public void onLvSuccess(BaseRes<InventionListBean> baseRes) {
                    SvipActivity.this.loading.dismiss();
                    if (SvipActivity.this.binding != null && baseRes.getCode() == 200 && baseRes.getData() != null && baseRes.getData().getList() != null && baseRes.getData().getList().size() > 0) {
                        SvipActivity.this.adapterSvipType.setDomain(baseRes.getData().getDomain());
                        SvipActivity.this.adapterSvipType.setData(baseRes.getData().getList());
                    }
                }
            });
        }
    }

    /* access modifiers changed from: protected */
    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, com.androidx.p013lv.base.p015ui.BaseActivity
    public void onDestroy() {
        super.onDestroy();
        DialogLoading dialogLoading = this.loading;
        if (dialogLoading != null) {
            dialogLoading.dismiss();
            this.loading = null;
        }
    }

    @Override // com.androidx.p013lv.invention.OnInventionType
    public void onClick(InventionBean inventionBean, int i, int i2) {
        if (!isOnClick()) {
            if (i2 == R.id.btn_more) {
                int type = inventionBean.getType();
                if (type == 21) {
                    ARouter.getInstance().build(Constance.SVIP_GOLD_ACTIVITY).withString(Key.TXT, inventionBean.getStationName()).withInt("type", inventionBean.getStationId()).navigation();
                }
                if (type == 22) {
                    ARouter.getInstance().build(Constance.SVIP_GOLD_ACTIVITY).withString(Key.TXT, inventionBean.getStationName()).withInt("type", inventionBean.getStationId()).navigation();
                }
                if (type == 23) {
                    ARouter.getInstance().build(Constance.SVIP_RECOMMEND_ACTIVITY).withString(Key.TXT, inventionBean.getStationName()).withInt("type", inventionBean.getStationId()).navigation();
                }
            } else if (i2 == R.id.btn_swap && inventionBean.getType() == 22) {
                swapOne(inventionBean, i);
            }
        }
    }

    /* access modifiers changed from: package-private */
    public void swapOne(InventionBean inventionBean, final int i) {
        if (inventionBean.getVideoList() != null && inventionBean.getVideoList().size() != 0) {
            HttpUtils.getInsatance().get(UrlManager.getInsatance().queryBatchVideo(inventionBean.getStationId(), 4, inventionBean.getVideoList().get(inventionBean.getVideoList().size() - 1).getVideoId()), new HttpCallback<BaseRes<TwoBean>>("swapOne") {
                /* class com.grass.p019lv.activity.SvipActivity.C29093 */

                public void onLvSuccess(BaseRes<TwoBean> baseRes) {
                    if (baseRes.getCode() == 200) {
                        ((InventionBean) SvipActivity.this.adapterSvipType.getDataInPosition(i)).setVideoList(baseRes.getData().getList());
                        SvipActivity.this.adapterSvipType.notifyItemChanged(i);
                        return;
                    }
                    ToastUtils.getInstance().showWeak(baseRes.getMsg());
                }
            });
        }
    }

    /* renamed from: com.grass.lv.activity.SvipActivity$OnClick */
    public class OnClick {
        public OnClick() {
        }

        public void btnBack() {
            if (!SvipActivity.this.isOnClick()) {
                SvipActivity.this.finish();
            }
        }
    }
}
